{{extend 'layout.html'}}

<div class="module">
	<div class="module-body">
		<ul class="nav nav-tabs">
			<li class="active"><a href="#ricevute" data-toggle="tab">{{=T("Richeste ricevute")}}</a></li>				
			<li><a href="#inviate" data-toggle="tab">{{=T("Richieste inviate")}}</a></li>
		</ul>
		<div id="myTabContent" class="tab-content">
			<div class="tab-pane active in" id="ricevute">		
				<table>
					{{for friend in friends:}}
						<tr>
							<td>
								<img class="nav-avatar" src="{{=URL('default', 'download', args=db.auth_user(friend.auth_user.id).thumbnail)}}">
								{{=A(name_of(friend.auth_user), _href=URL('wall', args=friend.auth_user.id))}}
							</td>
							<td>
								{{btn = XML("<button class='btn disabled' type='button'>%s</button>"%T("Accettata"))}}
								{{if friend.amicizie.is_accettata:}}
									{{=btn}}										
								{{else:}}
									<button onclick="ajax('{{=URL('friendship', args=('accept',friend.auth_user.id))}}',[], null);jQuery(this).parent().html('{{=btn}}')">
										{{=T("Accetta")}}
									</button>
								{{pass}}
							</td>
							<td>
								<button onclick="ajax('{{=URL('friendship', args=('deny',friend.auth_user.id))}}',[], null);jQuery(this).parent().html('denied')">
									{{=T("Rifiuta")}}
								</button>
							</td>
						</tr>
					{{pass}}
				</table>																								
			</div>												
			<div class="tab-pane fade" id="inviate">
				<table>
					{{for friend in requests:}}
						<tr>
							<td>
								<img class="nav-avatar" src="{{=URL('default', 'download', args=db.auth_user(friend.auth_user.id).thumbnail)}}">
								{{=A(name_of(friend.auth_user), _href=URL('wall',args=friend.auth_user.id))}}
							</td>
							<td>
								{{if friend.amicizie.is_accettata:}}
									{{T("Accettata")}}
								{{else:}}
									{{T("In attesa di approvazione")}}
								{{pass}}
							</td>
							<td>
								<button onclick="ajax('{{=URL('friendship', args=('remove', friend.auth_user.id))}}',[], null);jQuery(this).parent().html('removed')">
									{{=T("Rimuovi")}}
								</button>
							</td>
						</tr>
					{{pass}}
				</table>		
			</div>	
		</div>
	</div>
</div>
